﻿@using Apps.Web.Core;
@using Apps.Web;
@using Apps.Common;
@using Apps.Models.Sys;
@using Apps.Locale;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    List<permModel> perm = null;
    //岩相管理
}

<div id="uploadExcel" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,shadow:false">
    <form name="form1" method="post" id="form1">
        <table>
            <tr>
                <th style="padding:20px; "> Excel：</th>
                <td style="padding:20px; ">
                    <input name="ExcelPath" type="text" maxlength="255" id="txtExcelPath" readonly="readonly" style="width:200px" class="txtInput normal left">
                    <a href="javascript:$('#FileUpload').trigger('click').void(0);" class="files">@Resource.Browse</a>
                    <input class="displaynone" type="file" id="FileUpload" name="FileUpload" onchange="Upload('ExcelFile', 'txtExcelPath', 'FileUpload'); ">
                    <span class="uploading">@Resource.Uploading</span>
                </td>
            </tr>
        </table>
        <div class="endbtndiv">
            <a id="btnSave" href="javascript:ImportData()" class="easyui-linkbutton btns">直接保存</a>
            <a id="btnReturn" href="javascript:$('#uploadExcel').window('close')" class="easyui-linkbutton btnc">@Resource.Cancel</a>
        </div>
    </form>
</div>
<div class="mvctool">
    <input id="txtTestCode" type="text" class="searchText" placeholder="化验编码" />
    <input id="txtBatchCode" type="text" class="searchText" placeholder="批次编码" />
    <input id="txtName" type="text" class="searchText" placeholder="标题" />
    @Html.ToolButton("btnQuery", "fa fa-search", Resource.Query, ref perm, "Query", true)
    @Html.ToolButton("btnCreate", "fa fa-plus", Resource.Create, ref perm, "Create", true)
    @Html.ToolButton("btnEdit", "fa fa-pencil", Resource.Edit, ref perm, "Edit", true)
    @Html.ToolButton("btnExamine", "fa fa-check", "审核", ref perm, "Examine", true)
    @Html.ToolButton("btnDelete", "fa fa-trash", Resource.Delete, ref perm, "Delete", true)

</div>
<table id="List"></table>
@Html.Partial("~/Views/Shared/_Partial_AutoGrid.cshtml")

<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<script type="text/javascript">


    $(function () {
        $('#List').datagrid({
            url: '@Url.Action("GetList")',
            width: SetGridWidthSub(10),
            methord: 'post',
            height: SetGridHeightSub(45),
            fitColumns: true,
            sortName: 'ADDTIME',
            sortOrder: 'desc',
            idField: 'ID',
            pageSize: 15,
            pageList: [15, 20, 30, 40, 50],
            pagination: true,
            striped: true, //奇偶行是否区分
            singleSelect: true,//单选模式
            selectOnCheck: false,
            checkOnSelect: false,
            checkbox: true,
            rownumbers: true,//行号
            onLoadSuccess: function (data) {
            },
            columns: [[
                { field: 'YAN_ID', title: '附件编号', width: '10%', checkbox:true },
                { field: 'BATCH_CODE', title: '批次编码', width: '10%' },
                { field: 'TEST_CODE', title: '化验编码', width: '15%' },
                { field: 'ITEM_VALUE', title: '标准差%', width: '10%' },
                { field: 'ITEM_NAME', title: '附件标题', width: '45%' },
                { field: 'AUDIT_STATUS', title: '审核状态', width: '5%' },
                { field: 'AUDIT_TIME', title: '审核时间', width: '10%', sortable: true },
                { field: 'ADDTIME', title: '创建时间', width: '10%', sortable: true }
            ]], onClickRow: function (index, row) {
                if (row.ENABLED) {
                    $("#btnEnable").hide();
                    $("#btnDisable").show();
                }
                else {
                    $("#btnDisable").hide();
                    $("#btnEnable").show();
                }

            }
        });
    });
    //ifram 返回
    function frameReturnByClose() {
        $("#modalwindow").window('close');
    }

    function frameReturnByReload(flag) {
        if (flag)
            $("#List").datagrid('load');
        else
            $("#List").datagrid('reload');

        $("#List").datagrid("clearSelections"); //全部不选中
        $("#List").datagrid("clearChecked"); //全部不选中
        $("#List").datagrid("unselectAll"); //全部不选中
    }
    function frameReturnByMes(mes) {
        $.messageBox5s(Lang.Tip, mes);
    }
    $(function () {
        $("#btnCreate").click(function () {
            $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='auto' frameborder='0'' src='@Url.Action("Create")'></iframe>");
            $("#modalwindow").window({ title: Lang.Create, width: 900, height: 550, iconCls: 'fa fa-plus' }).window('open');
        });
        $("#btnEdit").click(function () {
            var row = $('#List').datagrid('getSelected');
            if (row != null) {
                $("#modalwindow").html("<iframe width='100%' height='99%'  frameborder='0' src='@Url.Action("Edit")?id=" + row.YAN_ID + "&Ieguid=" + GetGuid() + "'></iframe>");
                $("#modalwindow").window({ title: '@Resource.Edit', width: 900, height: 600, iconCls: 'fa fa-pencil' }).window('open');
            } else { $.messageBox5s(Lang.Tip, '@Resource.PlaseChooseToOperatingRecords'); }
        });
        $("#btnQuery").click(function () {
            var queryStr = $("#txtName").val();
            if (queryStr == null) {
                queryStr = "%";
            }
            $("#List").datagrid("load", {
                //txtTestCode txtBatchCode txtName
                collectCode: $("#txtTestCode").val() ,
                batchCode: $("#txtBatchCode").val() ,
                name: queryStr

            });

        });
         $("#btnExamine").click(function () {
             var formRow = $('#List').datagrid('getChecked');

             console.log(formRow,'ssformRow')
            if (formRow != null && formRow.length > 0) {
                if (formRow.length > 10) {
                    { $.messageBox5s(Lang.Tip, '一次最多审核10条记录'); }
                    return;
                }
                 var formIds = ""
                $.each(formRow, function (i, row) {
                    /* if (row.AUDIT_STATUS !="审核通过") {*/
                    if (1==1) {
                       if (formIds == "")
                        {
                           formIds = row.YAN_ID;
                        }
                        else {
                           formIds = formIds + "," + row.YAN_ID;
                        }
                    }
                });

                if (formIds == "") {
                    $.messageBox5s(Lang.Tip, '没有可审批记录');
                    return;
                }
                else {

                    $("#modalwindow").html("<iframe width='100%' height='99%'  frameborder='0' src='@Url.Action("Examine")?dataIds=" + formIds + "'></iframe>");
                    $("#modalwindow").window({ title: '审核', width: 400, height: 280, iconCls: 'fa fa-pencil' }).window('open');
                }
            }
            else
                {$.messageBox5s(Lang.Tip, '请至少选择一条记录');}
        });
        $("#btnDelete").click(function () {
            var row = $('#List').datagrid('getSelected');
            if (row != null) {
                $.messager.confirm(index_lang_tip, '@Resource.YouWantToDeleteTheSelectedRecords', function (r) {
                    if (r) {
                        $.post("@Url.Action("Delete")?id=" + row.YAN_ID, function (data) {
                            if (data.type == 1)
                                $("#List").datagrid('load');
                            $.messageBox5s(Lang.Tip, data.message);
                        }, "json");
                    }
                });
            } else { $.messageBox5s(Lang.Tip, '@Resource.PlaseChooseToOperatingRecords'); }
        });
    });
</script>

